package com.dream.myqiyi.service;

import java.util.HashMap;
import java.util.Map;


public class ApplicationContext {
	private Map<String, Object> beans; 

 	private static ApplicationContext singleton = null;
	/**
	 * Get the helper, possibly constructing it if necessary. For each call to this method, there should be 1 and only 1
	 * call to {@link #close()}.
	 */
	public static synchronized ApplicationContext getSingleton() {
		if (singleton == null) {
			singleton = new ApplicationContext();
		}
		return singleton;
	}

	public ApplicationContext() {
		beans = new HashMap<String, Object>();
	}
	
	public Object getBean(String name) {
		if (beans.containsKey(name)) {
			return beans.get(name);
		}
		return null;		
	}
	
	public void addBean(String name, Object bean) {
		if (beans.containsKey(name)) {
			return ;
		}
		beans.put(name, bean);
	}
	
	
}
